<?php
/**
 * 名师讲堂
 */

namespace app\api\controller;

use app\common\controller\ApiController;
use think\Exception;
use app\api\model\TeacherForum as TeacherForumModel;
use app\api\model\Banner as BannerModel;

class TeacherForum extends ApiController {

    protected $notNeedPhone = ['getlist', 'addplaynum'];
//    protected $notNeedToken = ['getlist', 'addplaynum'];

    /**
     * 名师讲堂
     * @return false|string
     */
    public function getList() {
        try {
            $params = $this->checkParams('');
            if ($params === false) {
                return $this->resErr();
            }
            $list = TeacherForumModel::getList($params);
            $banner = BannerModel::teacherForum();
            return $this->resData('success', ['page' => $list[2], 'count' => $list[1], 'pageNum' => $list[3], 'list' => $list[0], 'banner' => $banner]);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 增加播放量
     * @return false|string
     */
    public function addPlayNum() {
        try {
            $params = $this->checkParams('id');
            if ($params === false) {
                return $this->resErr();
            }
            $data = TeacherForumModel::addPlayNum($params);
            return $this->resData('操作成功', []);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}
